// pages/detail/detail.js
import Model from './model'
let model = new Model()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: [false, true, true],
    courrentSelect:['current','',''],
    courseInfo: '',
    courseLessons: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //课程详情
    model.getdetail().then((ret) => {
      this.setData({
        courseInfo: ret.data.data.courseDetail,
        courseLessons: ret.data.data.lessons
      })
    })
  },
  tabFun(evt) {
    var id = evt.currentTarget.dataset.id;
    this.data.show.forEach((item,index)=> {
      this.data.show[index] = true
      this.data.courrentSelect[index] = ''
    });
    this.data.show[id] = false
    this.data.courrentSelect[id] ='current'
    this.setData({
      show: this.data.show,
      courrentSelect: this.data.courrentSelect
    })
  }
})